package edu.mit.media.fv.components
{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	
	public class FVIconButton extends MovieClip
	{
		public static var PLAY:String = "playicontype";
		public static var STOP:String = "stopicontype";
		public static var RECORD:String = "recordicontype";
		
		private var filter:BevelFilter = new BevelFilter();
			
		private var infilter:BevelFilter = new BevelFilter(4,45,0,1,0xFFFFFF,1,4,4,1,1, BitmapFilterType.INNER);
		private var r:Sprite;
		private var s:Sprite;
		
		public function FVIconButton(type:String)
		{
			r = new Sprite();
			r.graphics.beginFill(0x888888, 1.0);
			//r.graphics.lineStyle(1,0xFFFFFF,0.7,true);
			r.graphics.drawRoundRect(0,0,100,100,15,15);
			r.graphics.endFill();
			this.addChild(r);
			
			s = new Sprite();
			if(type == PLAY){
				s.graphics.beginFill(0x00FF00, 1.0);
				s.graphics.lineStyle();
				s.graphics.moveTo(30,30);
				s.graphics.lineTo(70,50);
				s.graphics.lineTo(30,70);
				s.graphics.lineTo(30,30);
				s.graphics.endFill();
				
			}else if(type == STOP){
				s.graphics.beginFill(0xFF0000, 1.0);
				s.graphics.lineStyle();
				s.graphics.drawRoundRect(30,30,40,40,4,4);
				s.graphics.endFill();
			}else if(type == RECORD){
				s.graphics.endFill();
				s.graphics.beginFill(0xFF0000, 1.0);
				s.graphics.lineStyle();
				s.graphics.drawCircle(50,50,20);
				s.graphics.endFill();
			}
			this.addChild(s);
			
			r.filters = [filter];
			s.filters = [infilter];
			
			this.addEventListener(MouseEvent.MOUSE_UP, processMouseUp);
			this.addEventListener(MouseEvent.MOUSE_OUT, processMouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, processMouseDown);
		}
		private var isPressed:Boolean = false;
		private function processMouseUp(event:MouseEvent):void{
			if(this.isPressed){
				
			}
			this.isPressed = false;
			r.filters = [filter];
			//s.filters = [infilter];
		}
		private function processMouseDown(event:MouseEvent):void{
			this.isPressed = true;
			r.filters = [infilter];
			//s.filters = [filter];
		}
		private function processMouseOut(event:MouseEvent):void{
			this.isPressed = false;
			r.filters = [filter];
			//s.filters = [infilter];
		}

	}
}